package net.sdd.school.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sdd.common.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "登陆模块")
@RestController
@RequestMapping("/sddonline/user")
//@CrossOrigin
public class LoginController {

    /**
     * 模拟登陆, 返回json格式数据:
     * {"code":20000,"data":{"token":"admin"}}
     */
    @PostMapping("/login")
    @ApiOperation("登陆认证")
    public Result login(){
        return Result.ok().data("token","admin");
    }

    /**
     * 获取登陆信息, 返回json格式数据:
     * {"code":20000,"data":{"roles":"admin","name":"admin","avatar":".."}}
     */
    @GetMapping("/info")
    @ApiOperation("用户信息")
    public Result info(){
        return Result.ok()
                .data("roles","admin").data("name","admin")
                .data("avatar","https://my-bucket-test8080.oss-cn-shenzhen.aliyuncs.com/image/2.jpeg");
    }

    @PostMapping("/logout")
    @ApiOperation("退出")
    public Result logout(){
        return Result.ok();
    }
}
